#ifndef EFFECTS_MANAGER_H_
#define EFFECTS_MANAGER_H_

// INCLUDES //
#include "effect/effect.h"
#include "card/card_info.h"
#include <vector>
//////////////

/**
* Listener for EffectsManager.
* 
* @author dfoelber
**/
class EffectsListener
{
public:
	virtual ~EffectsListener() {}
	
	/**
	* An effect's state has changed.
	* 
	* @param effect The effect that is updated
	**/
	virtual void EffectStateChanged( Effect* effect ) = 0;
};

/**
* Collects the active effects and notifies listeners.
* 
* @author dfoelber
**/
class EffectsManager
{
public:
	/**
	* Singleton accessor
	* 
	* @return Singleton instance
	**/
	static EffectsManager* GetManager();
	
	/**
	* Deconstructor
	**/
	~EffectsManager();
	
	/**
	* Notifies of time passing.
	* 
	* @param The amount of time, in milliseconds, that passed since the last call
	**/
	void TimePassed( int ms );

	/**
	* Adds a listener.
	* 
	* @param listener The listener
	**/
	void AddListener(EffectsListener* listener);
	
	/**
	* Processes the card and notifies listeners.
	* 
	* @param info The card info that is activated
	* @param player If the source was the player
	**/
	void CardActivated(CardInfo* info, bool player = true);
	
	/**
	* Notifies the manager that the effect has changed state.
	* 
	* @param effect The effect
	* @param state The new state
	**/
	void ChangeEffectState(Effect* effect, string state);
	
	/**
	* Reverses the target and origin of an effect (recursive to all dependent effects).
	* 
	* @param effect The effect to reverse
	**/
	void ReverseTarget(Effect* effect);
	
private:
	/**
	* Private Constructor
	**/
	EffectsManager();
	
	/**
	* Accesses the prerequisites for each effect and starts them if they are ready.
	**/
	void CheckPrereqs();
	
private:
	/**
	* Singleton instance
	**/
	static EffectsManager* 			instance;
	
	/**
	* The listeners
	**/
	vector<EffectsListener*>		listeners;
	
	/**
	* The list of effects
	**/
	vector<Effect* >				effects;
};

#endif /*EFFECTS_MANAGER_H_*/
